//
//  DlnaItemCapsule.m
//  MultiScreens
//
//  Created by apple on 14-12-23.
//  Copyright (c) 2014年 skyworth.digital. All rights reserved.
//

#import "DlnaItemCapsule.h"

static const NSString *PROCOTOL_MOUDP = @"moudp";
static const NSString *BUSINESS_MEDIAPLAY = @"mediaplay";
static const NSString *BUSINESS_MIRROR = @"mirror";
static const NSString *RESOLUTION_HHD = @"hhd";
static const NSString *RESOLUTION_HD = @"hd";
static const NSString *RESOLUTION_BD = @"bd";
static const NSString *MODE_NORMAL = @"normal";
static const NSString *MODE_SPEED = @"speed";



@implementation DlnaItemCapsule

@end

@implementation DlnaDevice


-(NSString*)serverIp{
    if (_serverIp == nil) {
        NSRange portRange = [self.descriptionUrl rangeOfString:@":10243"];
        if (portRange.length ==0) {
            return nil;
        }
        _serverIp = [self.descriptionUrl substringToIndex:portRange.location];
    }
    return _serverIp;
}

-(id)initWithUuid:(NSString *)uuid FriendlyName:(NSString *)friendlyName Type:(NSString *)type DescriptionUrl:(NSString *)descriptionUrl{
    self = [super init];
    if (!self) {
        return nil;
    }
    
    self.uuid = uuid;
    self.friendlyName = friendlyName;
    self.type = type;
    self.descriptionUrl = descriptionUrl;
    
    return self;
}


//http://192.168.6.90:8080/mediaService.play?procotol=moudp&&business=mediaplay&&mode=speed&&channid=7&&resolution=bd
+(NSString*)generateUrlWithServerIp:(NSString *)serverIp ChannelID:(NSString *)channelID{
    
    return [NSString stringWithFormat:@"%@:8080/mediaService.play?procotol=%@&&business=%@&&mode=%@&&channid=%@&&resolution=%@",serverIp,PROCOTOL_MOUDP,BUSINESS_MEDIAPLAY,MODE_SPEED,channelID,RESOLUTION_BD];
}
+(NSString*)generateMirrorUrlWithServerIp:(NSString *)serverIp{

    return [NSString stringWithFormat:@"%@:8080/mediaService.play?procotol=%@&&business=%@&&mode=%@&&channid=-1&&resolution=%@",serverIp,PROCOTOL_MOUDP,BUSINESS_MIRROR,MODE_SPEED,RESOLUTION_BD];

}
@end